package com.ruoyi.project.wodemand.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.wodemand.domain.TInfoSheetinfo;
import com.ruoyi.project.wodemand.service.ITInfoSheetinfoService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 工单Controller
 * 
 * @author lt
 * @date 2020-04-14
 */
@RestController
@RequestMapping("/wodemand/SHEETINFO")
public class TInfoSheetinfoController extends BaseController
{
    @Autowired
    private ITInfoSheetinfoService tInfoSheetinfoService;

    /**
     * 查询工单列表
     */
    @PreAuthorize("@ss.hasPermi('wodemand:SHEETINFO:list')")
    @GetMapping("/list")
    public TableDataInfo list(TInfoSheetinfo tInfoSheetinfo)
    {
        startPage();
        List<TInfoSheetinfo> list = tInfoSheetinfoService.selectTInfoSheetinfoList(tInfoSheetinfo);
        return getDataTable(list);
    }

    /**
     * 导出工单列表
     */
    @PreAuthorize("@ss.hasPermi('wodemand:SHEETINFO:export')")
    @Log(title = "工单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TInfoSheetinfo tInfoSheetinfo)
    {
        List<TInfoSheetinfo> list = tInfoSheetinfoService.selectTInfoSheetinfoList(tInfoSheetinfo);
        ExcelUtil<TInfoSheetinfo> util = new ExcelUtil<TInfoSheetinfo>(TInfoSheetinfo.class);
        return util.exportExcel(list, "SHEETINFO");
    }

    /**
     * 获取工单详细信息
     */
    @PreAuthorize("@ss.hasPermi('wodemand:SHEETINFO:query')")
    @GetMapping(value = "/{sheetId}")
    public AjaxResult getInfo(@PathVariable("sheetId") Long sheetId)
    {
        return AjaxResult.success(tInfoSheetinfoService.selectTInfoSheetinfoById(sheetId));
    }

    /**
     * 新增工单
     */
    @PreAuthorize("@ss.hasPermi('wodemand:SHEETINFO:add')")
    @Log(title = "工单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TInfoSheetinfo tInfoSheetinfo)
    {
        return toAjax(tInfoSheetinfoService.insertTInfoSheetinfo(tInfoSheetinfo));
    }

    /**
     * 修改工单
     */
    @PreAuthorize("@ss.hasPermi('wodemand:SHEETINFO:edit')")
    @Log(title = "工单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TInfoSheetinfo tInfoSheetinfo)
    {
        return toAjax(tInfoSheetinfoService.updateTInfoSheetinfo(tInfoSheetinfo));
    }

    /**
     * 删除工单
     */
    @PreAuthorize("@ss.hasPermi('wodemand:SHEETINFO:remove')")
    @Log(title = "工单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sheetIds}")
    public AjaxResult remove(@PathVariable Long[] sheetIds)
    {
        return toAjax(tInfoSheetinfoService.deleteTInfoSheetinfoByIds(sheetIds));
    }
}
